package com.ihemou.system.feign;

import com.ihemou.common.core.constant.Constants;
import com.ihemou.common.core.constant.ServiceNameConstants;
import com.ihemou.common.core.domain.R;
import com.ihemou.system.dto.SysSocialAppConfigDTO;
import com.ihemou.system.dto.SysUserDTO;
import com.ihemou.system.dto.UserInfo;
import com.ihemou.system.dto.WxUserInfoDTO;
import com.ihemou.system.feign.factory.RemoteUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 用户服务
 *
 * @author ruoyi
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @return 结果
     */
    @GetMapping(value = "/user/info/{username}")
    @ResponseBody
    public R<UserInfo> getUserInfo(@PathVariable("username") String username, @RequestHeader(Constants.SERVICE_REQUEST) String request);

    /**
     * 微信小程序登录注册账号
     * @param wxUserInfoDTO 微信用户信息
     * @return
     */
    @PostMapping("/inner/social/sysSocialUser/save")
    public R<UserInfo> addSocialUser(@RequestBody WxUserInfoDTO wxUserInfoDTO, @RequestHeader(Constants.SERVICE_REQUEST) String request);

    /**
     * 查询小程序的配置
     * @param appCode 小程序的code
     * @return
     */
    @GetMapping(value = "/inner/social/sysSocialAppConfig/{appCode}")
    public R<SysSocialAppConfigDTO> getAppConfig(@PathVariable("appCode") String appCode, @RequestHeader(Constants.SERVICE_REQUEST) String request);

    /**
     * 授权用户自动登录
     * @param wxUserInfoDTO
     * @param request
     * @return
     */
    @PostMapping("/inner/social/sysSocialUser/find")
    public R<UserInfo> findSocialUser(@RequestBody WxUserInfoDTO wxUserInfoDTO, @RequestHeader(Constants.SERVICE_REQUEST) String request);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param request 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUserDTO sysUser, @RequestHeader(Constants.SERVICE_REQUEST) String request);

}
